package com.clothes.act;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.clothes.R;
import com.clothes.adp.SelectAdapter;
import com.clothes.mdoel.ClothesTable;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ClaimSelect extends BaseActivity {

    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.lv)
    ListView lv;
    private List<ClothesTable> list = new ArrayList<>();
    private SelectAdapter adapter;

    @Override
    public void initView() {
        setContentView(R.layout.activity_claim_select);
        List<ClothesTable> mList = (List<ClothesTable>) getIntent().getSerializableExtra("list");
        //过滤list
        for (ClothesTable info : mList){
            if(info.getClaimed() - info.getSubmit() > 0 ){
                list.add(info);
            }
        }
    }

    @Override
    public void initData() {
        tvTitle.setText("交货选择");
        adapter = new SelectAdapter(this,list);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                ClothesTable info = list.get(i);
                Intent intent = new Intent();
                intent.putExtra("info",info);
                setResult(101,intent);
                onBackPressed();
            }
        });
    }

    @OnClick(R.id.iv_back)
    public void onViewClicked() {
        onBackPressed();
    }
}
